<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>title</title>

</head>
<body>
<script>
  //页面的任何的位置.按下键盘,获取按键的值
  document.onkeydown=function (e) {
    console.log(e.keyCode);//事件参数对象
  };
</script>

</body>
</html>